<?php
/**
 * This is the abstract Panel class for the List All functionality
 * of the SchoolUsedTitles class.  This code-generated class
 * contains a datagrid to display an HTML page that can
 * list a collection of SchoolUsedTitles objects.  It includes
 * functionality to perform pagination and sorting on columns.
 *
 * To take advantage of some (or all) of these control objects, you
 * must create a new QPanel which extends this SchoolUsedTitlesListPanelBase
 * class.
 *
 * Any and all changes to this file will be overwritten with any subsequent re-
 * code generation.
 *
 * @package My QCubed Application
 * @subpackage Drafts
 *
 */
class SchoolUsedTitlesListPanel extends QPanel {
    // Local instance of the Meta DataGrid to list SchoolUsedTitleses
    public $dtgSchoolUsedTitleses;
    public $pnlSchoolUsedEditTitles;
    // Other public QControls in this panel
    public $btnCreateNew;
    public $pxyEdit;

    // Callback Method Names
    protected $strSetEditPanelMethod;
    protected $strCloseEditPanelMethod;

    public function __construct($objParentObject, $strSetEditPanelMethod, $strCloseEditPanelMethod=null, $strControlId = null) {
        // Call the Parent
        try {
            parent::__construct($objParentObject, $strControlId);
        } catch (QCallerException $objExc) {
            $objExc->IncrementOffset();
            throw $objExc;
        }

        // Record Method Callbacks
        $this->strSetEditPanelMethod = $strSetEditPanelMethod;
        $this->strCloseEditPanelMethod = $strCloseEditPanelMethod;

        // Setup the Template
         $this->Template = __DOCROOT__ . __MARKETING__ . '/tpl/SchoolUsedTitlesListPanel.tpl.php';

         $this->pnlSchoolUsedEditTitles = New SchoolUsedTitlesEditPanel($this,"Close");


        // Instantiate the Meta DataGrid
        $this->dtgSchoolUsedTitleses = new SchoolUsedTitlesDataGrid($this);

        // Style the DataGrid (if desired)
        $this->dtgSchoolUsedTitleses->CssClass = 'datagrid';
        $this->dtgSchoolUsedTitleses->AlternateRowStyle->CssClass = 'alternate';

        // Add Pagination (if desired)
        $this->dtgSchoolUsedTitleses->Paginator = new QPaginator($this->dtgSchoolUsedTitleses);
        $this->dtgSchoolUsedTitleses->ItemsPerPage = 6;

        $this->dtgSchoolUsedTitleses->AdditionalConditions = QQ::Equal(QQN::SchoolUsedTitles()->OrgId, $_SESSION['Org']->Id) ;

        // Use the MetaDataGrid functionality to add Columns for this datagrid

        // Create an Edit Column
        $this->pxyEdit = new QControlProxy($this);
        $this->pxyEdit->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'pxyEdit_Click'));
        //$this->dtgSchoolUsedTitleses->MetaAddEditProxyColumn($this->pxyEdit, 'Edit', 'Edit');

        // Create the Other Columns (note that you can use strings for school_used_titles's properties, or you
        // can traverse down QQN::school_used_titles() to display fields that are down the hierarchy)

        //$this->dtgSchoolUsedTitleses->MetaAddColumn(QQN::SchoolUsedTitles()->Stage->Name);
        $this->dtgSchoolUsedTitleses->MetaAddTypeColumn('StageId', 'StageType');
        $this->dtgSchoolUsedTitleses->MetaAddColumn(QQN::SchoolUsedTitles()->Series);
        $this->dtgSchoolUsedTitleses->MetaAddColumn(QQN::SchoolUsedTitles()->UsedSince);
        $this->dtgSchoolUsedTitleses->MetaAddColumn('Note');
        $this->dtgSchoolUsedTitleses->MetaAddColumn('Euser');


        // Setup the Create New button
        $this->btnCreateNew = new QButton($this);
        $this->btnCreateNew->Text = QApplication::Translate('Create a New') . ' ' . QApplication::Translate('SchoolUsedTitles');
        $this->btnCreateNew->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCreateNew_Click'));
    }

    public function pxyEdit_Click($strFormId, $strControlId, $strParameter) {
        $strParameterArray = explode(',', $strParameter);
        $objEditPanel = new SchoolUsedTitlesEditPanel($this, $this->strCloseEditPanelMethod, $strParameterArray[0]);

        $strMethodName = $this->strSetEditPanelMethod;
        $this->objForm->$strMethodName($objEditPanel);
    }

    public function btnCreateNew_Click($strFormId, $strControlId, $strParameter) {
        $objEditPanel = new SchoolUsedTitlesEditPanel($this, $this->strCloseEditPanelMethod, null);
        $strMethodName = $this->strSetEditPanelMethod;
        $this->objForm->$strMethodName($objEditPanel);
    }
    public function CloseReOpenEditPanel() {
        $this->pnlSchoolUsedEditTitles->RemoveChildControls(true);
        $this->pnlSchoolUsedEditTitles->Visible = false;
        $this->pnlSchoolUsedEditTitles = New SchoolUsedTitlesEditPanel($this,"Close");
        $this->pnlSchoolUsedEditTitles->Visible = true;
    }
}
?>